<template>
    <div class="game-mode-container">
        <div class="game-mode-card">
            <div class="game-mode-header">
                <h1>人机模式 (PVE)</h1>
            </div>

            <div class="game-mode-content">
                <div class="mode-config pve-config">
                    <div class="config-section">
                        <h3>选择难度</h3>
                        <div class="difficulty-options">
                            <div
                                :class="{ active: difficultyLevel === 'easy' }"
                                class="difficulty-option"
                                @click="difficultyLevel = 'easy'"
                            >
                                简单
                            </div>
                            <div
                                :class="{ active: difficultyLevel === 'normal' }"
                                class="difficulty-option"
                                @click="difficultyLevel = 'normal'"
                            >
                                普通
                            </div>
                            <div
                                :class="{ active: difficultyLevel === 'hard' }"
                                class="difficulty-option"
                                @click="difficultyLevel = 'hard'"
                            >
                                困难
                            </div>
                            <div
                                :class="{ active: difficultyLevel === 'expert' }"
                                class="difficulty-option"
                                @click="difficultyLevel = 'expert'"
                            >
                                专家
                            </div>
                        </div>
                    </div>

                    <div class="mode-tips">
                        <p v-if="difficultyLevel === 'easy'">
                            适合初学者的难度，AI反应较慢。三个机器人，不会攻击。
                        </p>
                        <p v-else-if="difficultyLevel === 'normal'">
                            标准游戏体验，适合大多数玩家。五个机器人，随机选择对手攻击。
                        </p>
                        <p v-else-if="difficultyLevel === 'hard'">
                            具有挑战性的AI对手，反应迅速。五个机器人，全部瞄准你！
                        </p>
                        <p v-else-if="difficultyLevel === 'expert'">
                            极具挑战性，只适合高级玩家。七个机器人，全部瞄准你，无开局保护！彻底疯狂！
                        </p>
                    </div>

                    <div class="config-actions">
                        <button class="back-btn" @click="goBackToModeSelection">返回</button>
                        <button class="start-btn" @click="startGame">开始游戏</button>
                    </div>
                </div>
            </div>

            <div class="game-mode-footer">
                <button class="menu-btn" @click="goBack">
                    <el-icon>
                        <Back />
                    </el-icon>
                    返回主菜单
                </button>
            </div>
        </div>
    </div>
</template>

<script setup>
    import { ref } from 'vue'
    import { useRouter } from 'vue-router'
    import { ElMessage } from 'element-plus'
    import { Back } from '@element-plus/icons-vue'

    const router = useRouter()
    // 默认难度为普通
    const difficultyLevel = ref('normal')

    //返回主菜单
    const goBack = () => {
        router.push('/')
    }

    // 返回游戏模式选择
    const goBackToModeSelection = () => {
        router.push('/mode/')
    }

    // 开始游戏
    const startGame = () => {
        ElMessage.success(`已选择人机模式，难度：${difficultyLevel.value}`)

        router.push(`/pve-playground/${difficultyLevel.value}`)
    }
</script>

<style scoped>
    .game-mode-container {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        width: 100vw;
    }

    .game-mode-card {
        width: 800px;
        background-color: rgba(0, 0, 0, 0.7);
        border-radius: 12px;
        padding: 30px;
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
        border: 1px solid rgba(255, 215, 0, 0.3);
        color: #fff;
        animation: fadeIn 0.5s ease-in-out;
        transform: scale(1);
        transition: transform 0.3s ease;
    }

    .game-mode-card:hover {
        transform: scale(1.01);
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
    }

    .game-mode-header {
        text-align: center;
        margin-bottom: 30px;
        border-bottom: 1px solid rgba(255, 215, 0, 0.3);
        padding-bottom: 15px;
    }

    .game-mode-header h1 {
        font-size: 28px;
        color: #ffd700;
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
        margin: 0;
        letter-spacing: 2px;
    }

    .game-mode-content {
        margin-bottom: 30px;
    }

    /* 模式配置样式 */
    .mode-config {
        padding: 20px;
        background-color: rgba(255, 255, 255, 0.05);
        border-radius: 10px;
        border: 1px solid rgba(255, 215, 0, 0.2);
    }

    .config-section {
        margin-bottom: 25px;
    }

    .config-section h3 {
        font-size: 18px;
        color: #ffd700;
        margin-bottom: 15px;
    }

    .difficulty-options {
        display: flex;
        justify-content: space-between;
        gap: 15px;
        margin-bottom: 20px;
    }

    .difficulty-option {
        flex: 1;
        padding: 12px;
        text-align: center;
        background-color: rgba(255, 255, 255, 0.1);
        border-radius: 6px;
        cursor: pointer;
        transition: all 0.3s;
    }

    .difficulty-option:hover {
        background-color: rgba(255, 255, 255, 0.2);
    }

    .difficulty-option.active {
        background-color: rgba(255, 215, 0, 0.3);
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    }

    .mode-tips {
        padding: 15px;
        background-color: rgba(255, 255, 255, 0.05);
        border-radius: 6px;
        margin-bottom: 25px;
        min-height: 60px;
    }

    .mode-tips p {
        margin: 0;
        font-size: 16px;
        color: rgba(255, 255, 255, 0.9);
    }

    .config-actions {
        display: flex;
        justify-content: space-between;
        margin-top: 20px;
    }

    .back-btn,
    .start-btn,
    .menu-btn {
        padding: 12px 25px;
        border-radius: 6px;
        font-size: 16px;
        font-weight: bold;
        border: none;
        cursor: pointer;
        transition: all 0.3s;
    }

    .back-btn {
        background-color: #666;
        color: white;
    }

    .back-btn:hover {
        background-color: #555;
    }

    .start-btn {
        background-color: #ffd700;
        color: #000;
    }

    .start-btn:hover {
        background-color: #ffc000;
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    }

    .game-mode-footer {
        display: flex;
        justify-content: center;
        margin-top: 20px;
        padding-top: 20px;
        border-top: 1px solid rgba(255, 215, 0, 0.3);
    }

    .menu-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        background-color: rgba(255, 255, 255, 0.1);
        color: white;
        border: 1px solid rgba(255, 215, 0, 0.3);
    }

    .menu-btn:hover {
        background-color: rgba(255, 255, 255, 0.2);
        transform: translateY(-3px);
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(-20px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
</style>
